#include<iostream>
using namespace std;
long long a,b,n,l,r;
int main(){
	freopen("candy.in","r",stdin);
	freopen("candy.out","w",stdout);
	cin >> n >> l >> r;
	a = l%n;
	b = r-l;
	if(a+b>=n-1){
		cout << n-1;
	}else{
		cout << a+b;
	}
	return 0;
}
